home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-03 | 6.3 KB | 261 lines | [TEXT/CWIE] |
- //========================================================================================
- //
- // File: Part.cpp
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "AMSample.hpp"
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- #ifndef BINDING_K
- #include "Binding.k"
- #endif
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef SELECT_H
- #include "Select.h"
- #endif
-
- // ----- Framework Layer -----
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWMENU_H
- #include "FWMenu.h"
- #endif
-
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h"
- #endif
-
- #ifndef FWRESTYP_H
- #include "FWResTyp.h"
- #endif
-
- #ifndef FWSUSINK_H
- #include "FWSUSink.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWBARRAY_H
- #include "FWBArray.h"
- #endif
-
- #ifndef FWABOUT_H
- #include "FWAbout.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWFLOWIN_H
- #include "FWFloWin.h" // FW_CFloatingWindow
- #endif
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- #ifndef FWSTRS_H
- #include "FWStrs.h"
- #endif
-
- #ifndef FWSUSINK_H
- #include "FWSUSink.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_ODTranslation_xh
- #include <Translt.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- //========================================================================================
- // Constants and Globals
- //========================================================================================
-
- #define kMainPresentation "BowersDev:Presentation:AMSample"
-
- //========================================================================================
- // Runtime info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment AMSample
- #endif
-
- FW_DEFINE_AUTO(CAMSamplePart)
-
- //========================================================================================
- // CAMSamplePart class
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CAMSamplePart constructor
- //----------------------------------------------------------------------------------------
-
- CAMSamplePart::CAMSamplePart(ODPart* odPart) :
- FW_CPart(odPart, FW_gInstance, kPartInfoID),
- fPartContent(NULL),
- fMainPresentation(NULL)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CAMSamplePart destructor
- //----------------------------------------------------------------------------------------
-
- CAMSamplePart::~CAMSamplePart()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CAMSamplePart::Initialize
- //----------------------------------------------------------------------------------------
-
- void CAMSamplePart::Initialize(Environment* ev)
- {
- FW_CPart::Initialize(ev);
-
- // ----- Register Presentations
- fMainPresentation = RegisterPresentation(ev, kMainPresentation, TRUE,
- FW_NEW(CAMSampleSelection, (ev, fPartContent)));
-
- // ----- Initialize my menu -----
- GetMenuBar(ev)->InitializeFromResource(ev, kMenuBar);
- }
-
- //----------------------------------------------------------------------------------------
- // CAMSamplePart::NewFrame
- //----------------------------------------------------------------------------------------
-
- FW_CFrame* CAMSamplePart::NewFrame(Environment* ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- FW_Boolean fromStorage)
- {
- FW_UNUSED(fromStorage);
- FW_CFrame* newFrame = NULL;
-
- if (presentation == fMainPresentation) {
- newFrame = FW_NEW(CAMSampleFrame, (ev, odFrame, presentation, fPartContent));
- }
- return newFrame;
- }
-
- //------------------------------------------------------------------------------
- // CAMSamplePart::NewPartContent
- //------------------------------------------------------------------------------
-
- FW_CContent* CAMSamplePart::NewPartContent(Environment* ev)
- {
- fPartContent = FW_NEW(CAMSampleContent, (ev, this));
- return fPartContent;
- }
-
- //----------------------------------------------------------------------------------------
- // CAMSamplePart::DoMenu
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CAMSamplePart::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
- {
- FW_Boolean menuHandled = TRUE;
- ODCommandID id = theMenuEvent.GetCommandID(ev);
-
- switch (id)
- {
- case cStuffCommand:
- case cMoreStuffCommand:
- case cStillMoreCommand:
- this->DoAMSampleCommand(ev, id);
- menuHandled = TRUE;
- break;
-
- case kODCommandAbout:
- ::FW_About(ev, this, kAbout);
- break;
-
- default:
- menuHandled = FALSE;
- }
-
- return menuHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CAMSamplePart::DoAdjustMenus
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CAMSamplePart::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar,
- FW_Boolean hasMenuFocus,
- FW_Boolean isRoot)
- {
- if (hasMenuFocus)
- {
- menuBar->EnableCommand(ev, cStuffCommand, TRUE);
- menuBar->EnableCommand(ev, cMoreStuffCommand, TRUE);
- menuBar->EnableCommand(ev, cStillMoreCommand, TRUE);
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // CAMSamplePart::DoAMSampleCommand
- //----------------------------------------------------------------------------------------
-
- void CAMSamplePart::DoAMSampleCommand(Environment* ev, ODCommandID id)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CAMSamplePart::PartChanged
- //----------------------------------------------------------------------------------------
-
- void CAMSamplePart::PartChanged(Environment* ev)
- {
- // Mark the document's draft as changed so it can be saved
- this->Changed(ev);
-
- // Mark the display frame as changed, so that containing parts can update links
- fMainPresentation->ContentUpdated(ev);
-
- // Force all display frames to be redrawn
- fMainPresentation->Invalidate(ev);
- }
-